@if(isset($carts) && $carts)
    @php
        $total_price = 0;
        $freight_where = \App\Services\ConfigService::get('freight_where',0);
        $freight_price = \App\Services\ConfigService::get('freight',0);
    @endphp
    <div class="cart-product">
        <div class="cart-product-box ">
            @foreach($carts as $item)
                <div class="cart-product-item clearfix" id="cart-box">
                    <div class="cart-box-img-m"><img src="{{ $item->m_shopping_img?asset('uploads/'.$item->m_shopping_img):($item->m_img?asset('uploads/'.$item->m_img):asset('uploads/'.$item->img)) }}" alt="{{ $item->name }}"></div>
                    <div class="cart-product-info">
                        <p class="title">{{ $item->m_name?:$item->name }}</p>

                        <p class="price">NT${{ round($item->price) }}</p>
                        <div class="su-cart">
                            <i data-id="{{ $item->id }}" class="iconfont cart-action-reduce {{ $item->cart_num<=1?"forbid":"" }}">&#xe60f;</i>
                            <input class="cart-input cart-action-num" name="cart_num_shw" value="{{ $item->cart_num }}" readonly type="text" id="cart-input-{{ $item->id }}" data-price="{{ $item->price }}" data-cart-action="calc">
                            <i data-id="{{ $item->id }}" class="iconfont cart-action-add">&#xe604;</i>
                        </div>
                    </div>
                    <a href="javascript:;" class="cart-remove cart-action-remove" data-id="{{ $item->id }}"><i class="iconfont">&#xe70c;</i></a>
                </div>
                @php
                    $total_price = $total_price+ ($item->cart_num*$item->price);
                @endphp
            @endforeach
        </div>
    </div>
    @php
        $discount = \App\Services\DecrementService::full($total_price);
    @endphp
    <div class="cart-bottom">
        <div class="center">
            <div class="price-count">
                <p><label for="">商品總額：</label>NT$<span id="cart_total_price">{{ $total_price }}</span></p>
                <p id="cart_discount_row" style="display: {{ $discount['is']?"block":"none" }}"><label for="">滿減優惠：</label>-NT$<span id="cart_discount_price">{{ $discount['is']?$discount['discount_price']:"" }}</span></p>
                <p><label for="">運費：</label>NT$<span id="apex-cart-freight-price">{{ $total_price>=$freight_where?0:$freight_price }}</span></p>
                <p style="font-size: 0.2rem;">（購物滿三千免運費）</p>
                {{--<p><label for="">支付總額：</label>NT$<span id="apex-cart-sub-total">{{ $total_price>$freight_where?$total_price:$total_price+$freight_price }}</span></p>--}}
            </div>
            <a class="cate-cof" href="{{ url('shopping') }}">快速結賬</a>
        </div>
    </div>

@else
    <div class="cart-empty-tips">
        <p>購物袋空空如也~</p>
        <p>快去加入商品吧</p>
    </div>
    <div class="cart-bottom">
        <div class="center">
            <div class="price-count">
                <p><label for="">商品總額：</label>NT$<span id="cart_total_price">0</span></p>

                <p><label for="">運費：</label>NT$<span id="apex-cart-freight-price">{{ \App\Services\ConfigService::get('freight',0) }}</span></p>
                <p style="font-size: 0.2rem;">（購物滿三千免運費）</p>

            </div>

        </div>
    </div>
@endif

